package cn.hd01.web.config;

import java.io.IOException;
import java.math.BigDecimal;
import java.text.DecimalFormat;

import org.springframework.boot.jackson.JsonComponent;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

@JsonComponent
public class BigDecimalSerializer extends JsonSerializer<BigDecimal> {
	private DecimalFormat myformat = new DecimalFormat("#");

	@Override
	public void serialize(BigDecimal value, JsonGenerator gen, SerializerProvider serializers)
			throws IOException, JsonProcessingException {
		gen.writeString(myformat.format(value));
	}
}